package C_Paper;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @Auther: zzx
 * @Date: 2024.04.24/4/10
 */
public class C100_14 {
    //虚拟投资
    /*
    5 100 10
    10 20 30 40 50
    3 4 5 6 10
    20 30 20 40 30

    5 100 10
    10 20 30 40 500
    3 4 5 6 10
    20 30 20 40 30
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int cp = sc.nextInt();
        int tz = sc.nextInt();
        int fx = sc.nextInt();
        int[][] bank = new int[cp][3];
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < cp; j++) {
                bank[j][i] = sc.nextInt();
            }
        }
        System.out.println(Arrays.deepToString(bank));
        int[] mm = new int[2];
        int max = 0;
        for (int i = 0; i < cp; i++) {
            if (bank[i][1] <= fx && bank[i][2] <= tz){
                int tem = bank[i][2] * bank[i][0];
                if (tem > max){
                    max = tem;
                    mm[0] = -1;
                    mm[1] = i;
                }
            }
            for (int j = i + 1; j < cp; j++) {
                if (bank[i][1] + bank[j][1] <= fx && bank[i][2] + bank[j][2] <= tz){
                    int temp = bank[i][0]*bank[i][2] + bank[j][0]*bank[j][2];
                    if (temp > max){
                        max = temp;
                        mm[0] = i;
                        mm[1] = j;
                    }
                }
            }
        }
        System.out.println(Arrays.toString(mm));
    }
}
